package com.yugao.fintech.draper.auth.controller;

import cn.hutool.core.lang.Dict;
import com.yugao.fintech.draper.core.model.ResultVO;
import com.yugao.fintech.draper.security.config.properties.GiteeProperties;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequiredArgsConstructor
@RestController
@RequestMapping("/configuration")
public class ConfigurationEndpoint {
	private final ObjectProvider<GiteeProperties> giteePropertiesObjectProvider;
	
	@GetMapping
	public ResultVO<?> configuration() {
		Dict dict = Dict.create();
		giteePropertiesObjectProvider.ifAvailable(g -> dict.put("giteeAppid", g.getDefaultAppid()));
		return ResultVO.success(dict);
	}
}
